/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.statistics.targetResponsibility;

import com.koron.common.service.KpiStatisticsService;
import com.koron.report.management.StatisticsManagement;
import com.koron.report.mapper.statistics.AnnualSafPlanCompRateMapper;
import com.koron.report.statistics.StatisticsService;
import org.koron.ebs.mybatis.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 年度安全计划完成率
 */
@Service("annualSafPlanCompRateService")
@SuppressWarnings("deprecation")
public class AnnualSafPlanCompRateServiceImpl implements StatisticsService, InitializingBean {

    private final Logger logger = LoggerFactory.getLogger(AnnualSafPlanCompRateServiceImpl.class);

    @Autowired
    private StatisticsManagement statisticsManagement;

    @Autowired
    private KpiStatisticsService kpiStatisticsService;

    @Override
    public void statisticsMonth(int year, int month) {

    }

    @Override
    public void statisticsQuarter(int year, int quarter) {

    }

    @Override
    public void statisticsYear(int year) {
        // 年度安全计划完成率	公司	完成率不足100%	自动统计	计划完成项/计划总数*100%
        // 1.统计层级为集团、片区、公司
        // 2.工作计划、培训计划、检查计划、应急演练计划等
        try (SessionFactory factory = new SessionFactory()) {
            AnnualSafPlanCompRateMapper mapper = factory.getMapper(AnnualSafPlanCompRateMapper.class);
        } catch (Exception e) {
            logger.error("年度安全计划完成率按年(" + year + ")统计执行发生错误");
        }
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        Set<Object> handlers = statisticsManagement.getHandlers();
        handlers.add(this);
    }
}
